package com.cc.AOP;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class RecordTimeAspect {
    @Around("execution(* com.cc.controller.*.*(..))")
    public  Object  recordTime(ProceedingJoinPoint joinPoint) throws Throwable {
        //记录方法执行前的时间
        long begin=System.currentTimeMillis();

        //执行方法
        Object result=joinPoint.proceed();

        //记录方法执行结束时间
        long end= System.currentTimeMillis();

        log.info("执行时间：{}",end-begin);
        return result;


    }
}
